﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Tigera.T_Definition;

namespace Plugin.TradeSharp
{
    public partial class UCRiskSettingRule3 : UserControl
    {
        public UCRiskSettingRule3()
        {
            InitializeComponent();

            textBox_TotalNum.Text = 100000000.ToString();
            textBox_FloatNum.Text = 100000000.ToString();
        }
        public RiskStockLimit setting
        {
            get
            {

                RiskStockLimit ret = new RiskStockLimit();
                ret.Code = this.textBox_Product.Text;
                ret.FloatLimit = string.IsNullOrEmpty(this.textBox_Limit.Text) ? 0:  double.Parse(this.textBox_Limit.Text)/100;
                ret.FloatNum = string.IsNullOrEmpty(this.textBox_FloatNum.Text) ? 0: double.Parse(this.textBox_FloatNum.Text);
                ret.TotalLimit = string.IsNullOrEmpty(this.textBox_TotalLimit.Text) ? 0: double.Parse(this.textBox_TotalLimit.Text)/100;
                ret.TotalNum = string.IsNullOrEmpty(this.textBox_TotalNum.Text) ? 0 : double.Parse(this.textBox_TotalNum.Text);
                ret.PerInTolLimit = string.IsNullOrEmpty(this.textBox_PerInTolLimit.Text) ? 0 : double.Parse(this.textBox_PerInTolLimit.Text)/100;
                return ret;

            }
            set
            {
                this.textBox_Product.Text = value.Code  ;
                this.textBox_Limit.Text = (value.FloatLimit *100).ToString();
                this.textBox_FloatNum.Text = value.FloatNum.ToString();
                this.textBox_TotalLimit.Text = (value.TotalLimit*100).ToString();
                this.textBox_TotalNum.Text = value.TotalNum.ToString();
                this.textBox_PerInTolLimit.Text = (value.PerInTolLimit*100).ToString();

            }
        }
        public string Title
        {
            get
            {
                return "股本设置";
            }
        }

        //public String ProductCode
        //{
        //    get
        //    {
        //        return textBox_Product.Text;
        //    }
        //    set
        //    {
        //        textBox_Product.Text = value;
        //    }
        //}

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            Form parent = (this.Parent as Form);
            if (parent != null)
            {
                parent.DialogResult = DialogResult.Cancel;
                parent.Close();
            }
        }

        private void btn_OK_Click(object sender, EventArgs e)
        {
            Form parent = (this.Parent as Form);
            if (parent != null)
            {
                parent.DialogResult = DialogResult.OK;
                parent.Close();
            }          
            
        }
    }
}
